/*
	conditionLanguage/script.h
	@author:Wolfhead
*/
#ifndef WOLV_CONDITION_LANGUAGE_SCRIPT_H
#define WOLV_CONDITION_LANGUAGE_SCRIPT_H

#include <vector>
#include <string>
#include "condition.h"
#include "symbolTable.h"

namespace wolv
{
namespace condition
{

typedef const void * ScriptContext;
class LocalContext;

class Script
{
public:
	Script();
	~Script();

	int AddCondition(const std::string& name, const Condition& condition);
	
	std::string Exec(ScriptContext context, const std::string& label = "start");

	Script& LinkSymbol(SymbolImporter* importer);

	int GetLastError();
	const std::string& GetLastErrorMessage();

	const std::string& GetRawScript();
	int SetRawScript(const std::string& rawScript);

	void setError(int code, const std::string& message, const std::string& extra);

private:
	std::string _exec(const std::string& name, LocalContext* pContext);

	
	void clearError();

	std::map<std::string, Condition> scripts_;
	SymbolTable symbol_;

	std::string rawScript_;

	std::string currentLabel_;
	std::string errorMessage_;
	int errorCode_;
};




}//namespace condition
}//namespace wolv



#endif

